
#if !defined( __TF_LOG_H__)
#define __TF_LOG_H__

#if defined (__cplusplus)
extern "C"{
#endif

#include <stdio.h>
#include <stdarg.h>

/**
 * Log configuration MACRO
 * TF_USE_SYS_LOG   Whether use system log to record
 * TF_VERBOSE       Whether verbose every log to stdout
 */

#define INFO_LOG( info) \
    __TF_INFO_LOG( "INFO_LOG", info, __FILE__, __func__, __LINE__);

#define ERR_LOG( info) \
    __TF_INFO_LOG( "ERR_LOG", info, __FILE__, __func__, __LINE__)

#define __TF_INFO_LOG( prefix, info, file, func, line) \
    do{\
        tf_log( "[%s] %s (%s:%s:%d)\n", prefix, info, file, func, line);\
    }while(0)

#define ENTER_FUNC \
    __TF_RT_LOG( "RT_LOG", tf_log_indent_to, __func__,__FILE__, __LINE__, ">>");

#define LEAVE_FUNC \
    __TF_RT_LOG( "RT_LOG", tf_log_indent_from, __func__, __FILE__, __LINE__, "<<")

#define __TF_RT_LOG( prefix, indent, func, file, line, sign) \
    do{\
        tf_log("[%s]", prefix);\
        indent();\
        tf_log( " %s%s (%s:%d)\n", sign, func, file, line);\
    }while(0)

void tf_log( const char* format, ... );
void tf_log_init( );
void tf_log_destroy( void );
void tf_log_verbose( int mode);
void tf_log_mem_verbose( int mode);
void tf_log_indent_to();
void tf_log_indent_from();

#if defined( __cplusplus)
}   //extern "C"
#endif

#endif //#if !defined( __TF_LOG_H__)
